/**
  ******************************************************************************
  * @file   :   main.c
  * @version:
  * @author :
  * @brief  :
  ******************************************************************************
  * @attention
  *
  * <h2><center>&copy; Copyright(c) . BLUEX Microelectronics.
  * All rights reserved.</center></h2>
  *
  *
  ******************************************************************************
  */

/* includes ------------------------------------------------------------------*/

#include "bx_kernel.h"
#include "user_app.h"
#include "user_service_ble.h"
#include <easyflash.h>
#include "bx_shell.h"
/* private define ------------------------------------------------------------*/

/* private typedef -----------------------------------------------------------*/

/* private variables ---------------------------------------------------------*/

/* exported variables --------------------------------------------------------*/


/*============================= private function =============================*/

/*========================= end of private function ==========================*/


/*============================= exported function ============================*/
/** ---------------------------------------------------------------------------
 * @brief   :
 * @note    :
 * @param   :
 * @retval  :
-----------------------------------------------------------------------------*/
void user_init( void )
{
			us_ble_register();
}

/** ---------------------------------------------------------------------------
 * @brief   :
 * @note    :
 * @param   :
 * @retval  :
-----------------------------------------------------------------------------*/
void user_app( void )
{
		char key[12]="reboot_time";
		char key1[12]="device_name";
		char key2[9]="password";
		
		uint32_t Reboot_Time=1;
		char device[7]="sdk123";
		char password_buf[7]="123456";
		
		
		if ( easyflash_init() == EF_NO_ERR ) {
		
			ef_get_env_blob( key, &Reboot_Time, 4, NULL );
			
			ef_get_env_blob( key1, device, strlen(device)+1, NULL );
			
			ef_get_env_blob( key2, password_buf, strlen(password_buf)+1, NULL );

		}

		device[0]++;
		device[1]++;
		device[2]++;
		device[3]++;
		device[4]++;
		device[5]++;
		password_buf[0]++;
		password_buf[1]++;
		password_buf[2]++;
		password_buf[3]++;
		password_buf[4]++;
		password_buf[5]++;
		Reboot_Time++;
		
		
		ef_set_env_blob( key, &Reboot_Time, 4 );
//		sprintf(device,"sdk123");
		ef_set_env_blob( key1, device, 6);
//		sprintf(password_buf,"123456");
		ef_set_env_blob( key2, password_buf, 6);
		

		bxsh_log( "reboot_time is %d\r\n", Reboot_Time );
		bxsh_log( "device_name is %s\r\n", device );
		bxsh_log( "password is %s\r\n", password_buf );

	
}
/** ---------------------------------------------------------------------------
 * @brief   :
 * @note    :
 * @param   :
 * @retval  :
-----------------------------------------------------------------------------*/
bx_err_t user_msg_handle_func(s32 svc, u32 msg,u32 param0,u32 param1 )
{

    return BX_OK;
}
/*========================= end of exported function =========================*/


/*============================= import function ==============================*/

/*=========================== end of import function =========================*/


/*============================ interrupt function ============================*/

/*========================= end of interrupt function ========================*/

  
/******************** (C) COPYRIGHT BLUEX **********************END OF FILE****/



